package com.hyw.supply.controller;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.hyw.supply.model.entity.SupplyAccount;
import com.hyw.supply.model.vo.CommonResult;
import com.hyw.supply.service.SupplyAccountService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author zzp
 * @date 2024/3/14 11:17
 */

@RestController
@RequiredArgsConstructor
@Tag(name = "用户管理")
@RequestMapping("/user")
@Slf4j
public class UserController {


    private final SupplyAccountService accountService;

    @Operation(summary = "删除用户",hidden = true)
    @DeleteMapping("/del")
    public CommonResult<?> delUser() {
        List<SupplyAccount> list = accountService.lambdaQuery().list();
        //获取所有用户，并打印，保留日志
        log.info("用户信息打印开始：{}","..............................................................................");
        list.forEach(item->log.info("当前用户：{}", JSON.toJSONString(item)));
        log.info("用户信息打印结束，开始删除：{}","..............................................................................");
        accountService.lambdaUpdate().remove();
        return CommonResult.success(null);
    }
}
